package com.baidu.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.baidu.entity.PageResult;
import com.baidu.mapper.SportsMapper;
import com.baidu.pojo.Sports;
import com.baidu.service.SportsService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;

@Service(interfaceClass = SportsService.class)
public class SportsServiceImpl implements SportsService{
    @Autowired
    private SportsMapper sportsMapper;

    @Override
    public Sports findSportsById(Integer id) {
        return sportsMapper.findSportsById(id);
    }

    @Override
    public PageResult findByPage(Integer currentPage, Integer pageSize, String queryString) {
        PageHelper.startPage(currentPage,pageSize);
        Page<Sports> page=sportsMapper.findByPage(queryString);
        return new PageResult(page.getTotal(),page.getResult());
    }

    @Override
    public void addSports(Sports sports) {
        sportsMapper.addSports(sports);
    }

    @Override
    public void editSports(Sports sports) {
        sportsMapper.editSports(sports);
    }

    @Override
    public void deleteSportsById(Integer id) {
        sportsMapper.deleteSports(id);
    }
}
